/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.polytec.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Felix
 */
@Entity
@Table(name = "panier")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Panier.findAll", query = "SELECT p FROM Panier p"),
    @NamedQuery(name = "Panier.findByIdPanier", query = "SELECT p FROM Panier p WHERE p.idPanier = :idPanier"),
    @NamedQuery(name = "Panier.findBySommePanier", query = "SELECT p FROM Panier p WHERE p.sommePanier = :sommePanier")})
public class Panier implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_panier")
    private Integer idPanier;
    @Basic(optional = false)
    @NotNull
    @Column(name = "somme_panier")
    private double sommePanier;
    @OneToMany(mappedBy = "idPanier")
    private List<Commande> commandeList;
    @JoinColumn(name = "id_histo", referencedColumnName = "id_histo")
    @ManyToOne
    private HistoriqueDuPanier idHisto;
    @JoinColumn(name = "login", referencedColumnName = "login")
    @ManyToOne(optional = false)
    private Compte login;

    public Panier() {
    }

    public Panier(Integer idPanier) {
        this.idPanier = idPanier;
    }

    public Panier(Integer idPanier, double sommePanier) {
        this.idPanier = idPanier;
        this.sommePanier = sommePanier;
    }

    public Integer getIdPanier() {
        return idPanier;
    }

    public void setIdPanier(Integer idPanier) {
        this.idPanier = idPanier;
    }

    public double getSommePanier() {
        return sommePanier;
    }

    public void setSommePanier(double sommePanier) {
        this.sommePanier = sommePanier;
    }

    @XmlTransient
    public List<Commande> getCommandeList() {
        return commandeList;
    }

    public void setCommandeList(List<Commande> commandeList) {
        this.commandeList = commandeList;
    }

    public HistoriqueDuPanier getIdHisto() {
        return idHisto;
    }

    public void setIdHisto(HistoriqueDuPanier idHisto) {
        this.idHisto = idHisto;
    }

    public Compte getLogin() {
        return login;
    }

    public void setLogin(Compte login) {
        this.login = login;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPanier != null ? idPanier.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Panier)) {
            return false;
        }
        Panier other = (Panier) object;
        if ((this.idPanier == null && other.idPanier != null) || (this.idPanier != null && !this.idPanier.equals(other.idPanier))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.polytec.entities.Panier[ idPanier=" + idPanier + " ]";
    }
    
}
